<?php
class YouNet_View_Helper_SocialUrl extends Zend_View_Helper_Abstract{

    const CHEATING_CODE = 'cheating';
	public function __construct()
	{
	}

    /**
     * Get social url
     * @param string|array $uri
     * @return string
     */
	public function socialUrl($uri = array(),$name = null, $reset = false, $encode = true){
        // app_url / module / controller / action / parmas

        $social = YouNet_Api::getInstance()->getSocialPlugin();
        if( is_array($uri) )
        {
            /**
             * @todo [need to consider]
             */
            $uri[self::CHEATING_CODE] = self::CHEATING_CODE;
            $url = $this->view->url($uri,$name,$reset,$encode);
            $url = substr($url,strlen($this->view->baseUrl('/')) - 1);
            $url = str_replace('/'.self::CHEATING_CODE.'/'.self::CHEATING_CODE, '', $url);
            return $social->url($url);
        }
        return $social->url($uri);
	}
}